package org.zjx.test.tasks;

import org.zjx.task.RetryTask;
import org.zjx.context.ChainContext;
import org.zjx.task.core.TaskScheduler;

public class RetryTask1 extends RetryTask {

    public RetryTask1() {
        super("retryTask1");
    }
    @Override
    public void execute(ChainContext context, TaskScheduler scheduler) throws Exception {
        Thread.sleep(1000);
        if ((context.getCurrentChain().getRestartCount()) < 2) { // 前两次失败
            throw new Exception("Retry test failure");
        }
        System.out.println("RetryTask succeeded on retry " + context.getCurrentChain().getRestartCount());

    }
}
